/* Copyright 2001,2002,2003 NAH6 BV
 * All Rights Reserved
 *
 *  $Header: /var/lib/cvs/secphone/ui/controls/UnderLine.cpp,v 1.5 2003/11/21 12:39:24 itsme Exp $
 *
 *
 *  display a settable horizontal line.
 *
 *  no longer used.
 *
 *  was used for displaying an underline under one of the key-signature
 *  parts.
 *
 */

#include <afxwin.h>
#include "UnderLine.h"
#include "debug.h"

BEGIN_MESSAGE_MAP(UnderLine, CStatic)
    //{{AFX_MSG_MAP(UnderLine)
    ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

UnderLine::UnderLine()
{
    m_visible= false;
}

void UnderLine::Create(CDialog *dlg, const RECT& position)
{
    // create invisible window
    CStatic::Create(NULL, WS_CHILD|SS_BITMAP, position, dlg);

    CRect rect(position);

    int nbytes= 2*((rect.Width()+15)/16)*rect.Height();

    m_bits= new BYTE[ nbytes ];
    memset(m_bits, 0, nbytes);
    m_bmp.CreateBitmap(rect.Width(), rect.Height(), 1, 1, m_bits);

    debug("created bit map of %dx%d  at (%d,%d)  of %d bytes\n",
        rect.Width(), rect.Height(), rect.top, rect.right, nbytes);

    SetBitmap(m_bmp);

}

void UnderLine::Enable()
{
    m_visible= true;
    ShowWindow(SW_SHOW);
}

void UnderLine::Disable()
{
    m_visible= false;
    ShowWindow(SW_HIDE);
}

void UnderLine::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    CBrush br;
    COLORREF black= 0x00000000;

    CDC dc; dc.Attach(lpDrawItemStruct->hDC);
    dc.FillSolidRect(&lpDrawItemStruct->rcItem, black);
}

void UnderLine::OnClicked() 
{
    // -- ignoring click
    
}
